package com.fwzc.giuseppe.activity;

import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.fwzc.giuseppe.R;
import com.fwzc.giuseppe.adapter.UniversalAdapter;
import com.fwzc.giuseppe.base.BaseActivity;
import com.fwzc.giuseppe.entity.Logistic;
import com.fwzc.giuseppe.util.ViewHolder;
/**
 * 退换货的进度查看
 * @author llf
 *
 */
public class ProgressActivity extends BaseActivity implements OnClickListener{
	private ListView progress;
	private UniversalAdapter<Logistic> adapter;
	private List<Logistic> datas = new ArrayList<Logistic>();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_progress);
		
		initBar();
		initView();
		initListView();
	}
	
	private void initView() {
		actionbar_side_name.setText("进度查询");
		iv_actionbar_side_left.setVisibility(View.VISIBLE);
		iv_actionbar_side_left.setOnClickListener(this);

		progress = (ListView) findViewById(R.id.progress);
	}

	private void initListView() {
		for (int i = 0; i < 10; i++) {
			Logistic logistic = new Logistic();
			if (i == 0) {
				logistic.last_operation = true;
			} else {
				logistic.last_operation = false;
			}
			logistic.operation = "您的包裹已经在北京海定区包装" + i;
			logistic.time = "2015-06-25";
			datas.add(logistic);
		}
		
		adapter = new UniversalAdapter<Logistic>(this,datas,R.layout.logistic_item) {

			@Override
			public void convert(ViewHolder viewHolder, Logistic logistic) {
				ImageView point = (ImageView)viewHolder.getView(R.id.subsection_point);
				TextView operation = (TextView)viewHolder.getView(R.id.operation);
				TextView time = (TextView)viewHolder.getView(R.id.time);
				operation.setText(logistic.operation);
				time.setText(logistic.time);
				if(logistic.last_operation){
					point.setBackgroundResource(R.drawable.node_select);
					operation.setTextColor(getResources().getColor(R.color.pink));
				}else{
					point.setBackgroundResource(R.drawable.node_nomal);
					operation.setTextColor(getResources().getColor(R.color.time_line_text));
				}
			}
		};
		progress.setAdapter(adapter);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		// 返回
		case R.id.iv_actionbar_side_left:
			finish();
			break;

		default:
			break;
		}
	}
}
